<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<!--      <el-form-item label="设备Id" prop="deviceId">-->
<!--        <el-input-->
<!--          v-model="queryParams.deviceId"-->
<!--          placeholder="请输入设备Id"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="设备号" prop="deviceNo">-->
<!--        <el-input-->
<!--          v-model="queryParams.deviceNo"-->
<!--          placeholder="请输入设备号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="sim卡号" prop="simNum">-->
<!--        <el-input-->
<!--          v-model="queryParams.simNum"-->
<!--          placeholder="请输入sim卡号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="车辆Id" prop="carId">-->
<!--        <el-input-->
<!--          v-model="queryParams.carId"-->
<!--          placeholder="请输入车辆Id"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item label="车牌号" prop="carNo">
        <el-input
          v-model="queryParams.carNo"
          placeholder="请输入车牌号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
<!--      <el-form-item label="人员Id" prop="personId">-->
<!--        <el-input-->
<!--          v-model="queryParams.personId"-->
<!--          placeholder="请输入人员Id"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="人员姓名" prop="personName">-->
<!--        <el-input-->
<!--          v-model="queryParams.personName"-->
<!--          placeholder="请输入人员姓名"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="分组Id" prop="groupId">-->
<!--        <el-input-->
<!--          v-model="queryParams.groupId"-->
<!--          placeholder="请输入分组Id"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="分组名称" prop="groupName">-->
<!--        <el-input-->
<!--          v-model="queryParams.groupName"-->
<!--          placeholder="请输入分组名称"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="数据端口号" prop="devicePort">-->
<!--        <el-input-->
<!--          v-model="queryParams.devicePort"-->
<!--          placeholder="请输入数据端口号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="经度" prop="x">-->
<!--        <el-input-->
<!--          v-model="queryParams.x"-->
<!--          placeholder="请输入经度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="纬度" prop="y">-->
<!--        <el-input-->
<!--          v-model="queryParams.y"-->
<!--          placeholder="请输入纬度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="速度" prop="speed">-->
<!--        <el-input-->
<!--          v-model="queryParams.speed"-->
<!--          placeholder="请输入速度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="里程" prop="mileage">-->
<!--        <el-input-->
<!--          v-model="queryParams.mileage"-->
<!--          placeholder="请输入里程"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="油针值" prop="oilNeedle">-->
<!--        <el-input-->
<!--          v-model="queryParams.oilNeedle"-->
<!--          placeholder="请输入油针值"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="油量" prop="oilVolumn">-->
<!--        <el-input-->
<!--          v-model="queryParams.oilVolumn"-->
<!--          placeholder="请输入油量"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="方向" prop="direction">-->
<!--        <el-input-->
<!--          v-model="queryParams.direction"-->
<!--          placeholder="请输入方向"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="方向度数" prop="directionDegree">-->
<!--        <el-input-->
<!--          v-model="queryParams.directionDegree"-->
<!--          placeholder="请输入方向度数"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="GPS信号标记" prop="flag">-->
<!--        <el-input-->
<!--          v-model="queryParams.flag"-->
<!--          placeholder="请输入GPS信号标记"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="是否空载" prop="isNoload">-->
<!--        <el-input-->
<!--          v-model="queryParams.isNoload"-->
<!--          placeholder="请输入是否空载"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="是否设防" prop="isFortification">-->
<!--        <el-input-->
<!--          v-model="queryParams.isFortification"-->
<!--          placeholder="请输入是否设防"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="状态时长" prop="statusDuration">-->
<!--        <el-input-->
<!--          v-model="queryParams.statusDuration"-->
<!--          placeholder="请输入状态时长"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="车内温度" prop="temperature">-->
<!--        <el-input-->
<!--          v-model="queryParams.temperature"-->
<!--          placeholder="请输入车内温度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="总脉冲里程" prop="pulseOdo">-->
<!--        <el-input-->
<!--          v-model="queryParams.pulseOdo"-->
<!--          placeholder="请输入总脉冲里程"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="总脉冲数" prop="pulseCount">-->
<!--        <el-input-->
<!--          v-model="queryParams.pulseCount"-->
<!--          placeholder="请输入总脉冲数"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="脉冲速度" prop="pulseSpeed">-->
<!--        <el-input-->
<!--          v-model="queryParams.pulseSpeed"-->
<!--          placeholder="请输入脉冲速度"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="基站局号" prop="gsmloc">-->
<!--        <el-input-->
<!--          v-model="queryParams.gsmloc"-->
<!--          placeholder="请输入基站局号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="基站蜂窝号" prop="gsmci">-->
<!--        <el-input-->
<!--          v-model="queryParams.gsmci"-->
<!--          placeholder="请输入基站蜂窝号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="国家代号" prop="accuracy">-->
<!--        <el-input-->
<!--          v-model="queryParams.accuracy"-->
<!--          placeholder="请输入国家代号"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="事件代码" prop="eventCode">-->
<!--        <el-input-->
<!--          v-model="queryParams.eventCode"-->
<!--          placeholder="请输入事件代码"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="事件说明" prop="eventDesc">-->
<!--        <el-input-->
<!--          v-model="queryParams.eventDesc"-->
<!--          placeholder="请输入事件说明"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="报警类型列表" prop="alarmList">-->
<!--        <el-input-->
<!--          v-model="queryParams.alarmList"-->
<!--          placeholder="请输入报警类型列表"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
<!--      <el-form-item label="gps定位时间" prop="gpsTime">-->
<!--        <el-date-picker clearable-->
<!--          v-model="queryParams.gpsTime"-->
<!--          type="date"-->
<!--          value-format="yyyy-MM-dd"-->
<!--          placeholder="请选择gps定位时间">-->
<!--        </el-date-picker>-->
<!--      </el-form-item>-->
<!--      <el-form-item label="上报时间" prop="reportTime">-->
<!--        <el-input-->
<!--          v-model="queryParams.reportTime"-->
<!--          placeholder="请输入上报时间"-->
<!--          clearable-->
<!--          @keyup.enter.native="handleQuery"-->
<!--        />-->
<!--      </el-form-item>-->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['wx:devicelog:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['wx:devicelog:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['wx:devicelog:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['wx:devicelog:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="devicelogList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="日志id" align="center" prop="deviceLogId" />
      <el-table-column label="设备Id" align="center" prop="deviceId" />
      <el-table-column label="设备号" align="center" prop="deviceNo" />
      <el-table-column label="sim卡号" align="center" prop="simNum" />
      <el-table-column label="车辆Id" align="center" prop="carId" />
      <el-table-column label="车牌号" align="center" prop="carNo" />
      <el-table-column label="人员Id" align="center" prop="personId" />
      <el-table-column label="人员姓名" align="center" prop="personName" />
      <el-table-column label="分组Id" align="center" prop="groupId" />
      <el-table-column label="分组名称" align="center" prop="groupName" />
      <el-table-column label="数据端口号" align="center" prop="devicePort" />
      <el-table-column label="经度" align="center" prop="x" />
      <el-table-column label="纬度" align="center" prop="y" />
      <el-table-column label="速度" align="center" prop="speed" />
      <el-table-column label="里程" align="center" prop="mileage" />
      <el-table-column label="油针值" align="center" prop="oilNeedle" />
      <el-table-column label="油量" align="center" prop="oilVolumn" />
      <el-table-column label="方向" align="center" prop="direction" />
      <el-table-column label="方向度数" align="center" prop="directionDegree" />
      <el-table-column label="GPS信号标记" align="center" prop="flag" />
      <el-table-column label="发动机状态" align="center" prop="accStatus" />
      <el-table-column label="车门状态" align="center" prop="doorStatus" />
      <el-table-column label="后尾箱状态" align="center" prop="weightStatus" />
      <el-table-column label="寻求信息状态" align="center" prop="seekStatus" />
      <el-table-column label="是否空载" align="center" prop="isNoload" />
      <el-table-column label="是否设防" align="center" prop="isFortification" />
      <el-table-column label="实时状态" align="center" prop="realTimeStatus" />
      <el-table-column label="状态时长" align="center" prop="statusDuration" />
      <el-table-column label="车内温度" align="center" prop="temperature" />
      <el-table-column label="总脉冲里程" align="center" prop="pulseOdo" />
      <el-table-column label="总脉冲数" align="center" prop="pulseCount" />
      <el-table-column label="脉冲速度" align="center" prop="pulseSpeed" />
      <el-table-column label="基站局号" align="center" prop="gsmloc" />
      <el-table-column label="基站蜂窝号" align="center" prop="gsmci" />
      <el-table-column label="国家代号" align="center" prop="accuracy" />
      <el-table-column label="事件代码" align="center" prop="eventCode" />
      <el-table-column label="事件说明" align="center" prop="eventDesc" />
      <el-table-column label="报警类型列表" align="center" prop="alarmList" />
      <el-table-column label="车辆原始状态信息" align="center" prop="carStatus" />
      <el-table-column label="gps定位时间" align="center" prop="gpsTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.gpsTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="上报时间" align="center" prop="reportTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.reportTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['wx:devicelog:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['wx:devicelog:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改设备日志对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="设备号" prop="deviceNo">
          <el-input v-model="form.deviceNo" placeholder="请输入设备号" />
        </el-form-item>
        <el-form-item label="sim卡号" prop="simNum">
          <el-input v-model="form.simNum" placeholder="请输入sim卡号" />
        </el-form-item>
        <el-form-item label="车辆Id" prop="carId">
          <el-input v-model="form.carId" placeholder="请输入车辆Id" />
        </el-form-item>
        <el-form-item label="车牌号" prop="carNo">
          <el-input v-model="form.carNo" placeholder="请输入车牌号" />
        </el-form-item>
        <el-form-item label="人员Id" prop="personId">
          <el-input v-model="form.personId" placeholder="请输入人员Id" />
        </el-form-item>
        <el-form-item label="人员姓名" prop="personName">
          <el-input v-model="form.personName" placeholder="请输入人员姓名" />
        </el-form-item>
        <el-form-item label="分组Id" prop="groupId">
          <el-input v-model="form.groupId" placeholder="请输入分组Id" />
        </el-form-item>
        <el-form-item label="分组名称" prop="groupName">
          <el-input v-model="form.groupName" placeholder="请输入分组名称" />
        </el-form-item>
        <el-form-item label="数据端口号" prop="devicePort">
          <el-input v-model="form.devicePort" placeholder="请输入数据端口号" />
        </el-form-item>
        <el-form-item label="经度" prop="x">
          <el-input v-model="form.x" placeholder="请输入经度" />
        </el-form-item>
        <el-form-item label="纬度" prop="y">
          <el-input v-model="form.y" placeholder="请输入纬度" />
        </el-form-item>
        <el-form-item label="速度" prop="speed">
          <el-input v-model="form.speed" placeholder="请输入速度" />
        </el-form-item>
        <el-form-item label="里程" prop="mileage">
          <el-input v-model="form.mileage" placeholder="请输入里程" />
        </el-form-item>
        <el-form-item label="油针值" prop="oilNeedle">
          <el-input v-model="form.oilNeedle" placeholder="请输入油针值" />
        </el-form-item>
        <el-form-item label="油量" prop="oilVolumn">
          <el-input v-model="form.oilVolumn" placeholder="请输入油量" />
        </el-form-item>
        <el-form-item label="方向" prop="direction">
          <el-input v-model="form.direction" placeholder="请输入方向" />
        </el-form-item>
        <el-form-item label="方向度数" prop="directionDegree">
          <el-input v-model="form.directionDegree" placeholder="请输入方向度数" />
        </el-form-item>
        <el-form-item label="GPS信号标记" prop="flag">
          <el-input v-model="form.flag" placeholder="请输入GPS信号标记" />
        </el-form-item>
        <el-form-item label="是否空载" prop="isNoload">
          <el-input v-model="form.isNoload" placeholder="请输入是否空载" />
        </el-form-item>
        <el-form-item label="是否设防" prop="isFortification">
          <el-input v-model="form.isFortification" placeholder="请输入是否设防" />
        </el-form-item>
        <el-form-item label="状态时长" prop="statusDuration">
          <el-input v-model="form.statusDuration" placeholder="请输入状态时长" />
        </el-form-item>
        <el-form-item label="车内温度" prop="temperature">
          <el-input v-model="form.temperature" placeholder="请输入车内温度" />
        </el-form-item>
        <el-form-item label="总脉冲里程" prop="pulseOdo">
          <el-input v-model="form.pulseOdo" placeholder="请输入总脉冲里程" />
        </el-form-item>
        <el-form-item label="总脉冲数" prop="pulseCount">
          <el-input v-model="form.pulseCount" placeholder="请输入总脉冲数" />
        </el-form-item>
        <el-form-item label="脉冲速度" prop="pulseSpeed">
          <el-input v-model="form.pulseSpeed" placeholder="请输入脉冲速度" />
        </el-form-item>
        <el-form-item label="基站局号" prop="gsmloc">
          <el-input v-model="form.gsmloc" placeholder="请输入基站局号" />
        </el-form-item>
        <el-form-item label="基站蜂窝号" prop="gsmci">
          <el-input v-model="form.gsmci" placeholder="请输入基站蜂窝号" />
        </el-form-item>
        <el-form-item label="国家代号" prop="accuracy">
          <el-input v-model="form.accuracy" placeholder="请输入国家代号" />
        </el-form-item>
        <el-form-item label="事件代码" prop="eventCode">
          <el-input v-model="form.eventCode" placeholder="请输入事件代码" />
        </el-form-item>
        <el-form-item label="事件说明" prop="eventDesc">
          <el-input v-model="form.eventDesc" placeholder="请输入事件说明" />
        </el-form-item>
        <el-form-item label="报警类型列表" prop="alarmList">
          <el-input v-model="form.alarmList" placeholder="请输入报警类型列表" />
        </el-form-item>
        <el-form-item label="gps定位时间" prop="gpsTime">
          <el-date-picker clearable
            v-model="form.gpsTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择gps定位时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="上报时间" prop="reportTime">
          <el-input v-model="form.reportTime" placeholder="请输入上报时间" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {getDevicelog, listDevicelog,addDevicelog,updateDevicelog,delDevicelog} from "@/api/wx/devicelog";

  export default {
  name: "Devicelog",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 设备日志表格数据
      devicelogList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        deviceId: null,
        deviceNo: null,
        simNum: null,
        carId: null,
        carNo: null,
        personId: null,
        personName: null,
        groupId: null,
        groupName: null,
        devicePort: null,
        x: null,
        y: null,
        speed: null,
        mileage: null,
        oilNeedle: null,
        oilVolumn: null,
        direction: null,
        directionDegree: null,
        flag: null,
        accStatus: null,
        doorStatus: null,
        weightStatus: null,
        seekStatus: null,
        isNoload: null,
        isFortification: null,
        realTimeStatus: null,
        statusDuration: null,
        temperature: null,
        pulseOdo: null,
        pulseCount: null,
        pulseSpeed: null,
        gsmloc: null,
        gsmci: null,
        accuracy: null,
        eventCode: null,
        eventDesc: null,
        alarmList: null,
        carStatus: null,
        gpsTime: null,
        reportTime: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询设备日志列表 */
    getList() {
      this.loading = true;
      listDevicelog(this.queryParams).then(response => {
        this.devicelogList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        deviceLogId: null,
        deviceId: null,
        deviceNo: null,
        simNum: null,
        carId: null,
        carNo: null,
        personId: null,
        personName: null,
        groupId: null,
        groupName: null,
        devicePort: null,
        x: null,
        y: null,
        speed: null,
        mileage: null,
        oilNeedle: null,
        oilVolumn: null,
        direction: null,
        directionDegree: null,
        flag: null,
        accStatus: "0",
        doorStatus: "0",
        weightStatus: "0",
        seekStatus: "0",
        isNoload: null,
        isFortification: null,
        realTimeStatus: "0",
        statusDuration: null,
        temperature: null,
        pulseOdo: null,
        pulseCount: null,
        pulseSpeed: null,
        gsmloc: null,
        gsmci: null,
        accuracy: null,
        eventCode: null,
        eventDesc: null,
        alarmList: null,
        carStatus: "0",
        gpsTime: null,
        reportTime: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.deviceLogId)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加设备日志";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const deviceLogId = row.deviceLogId || this.ids
      getDevicelog(deviceLogId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改设备日志";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.deviceLogId != null) {
            updateDevicelog(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addDevicelog(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const deviceLogIds = row.deviceLogId || this.ids;
      this.$modal.confirm('是否确认删除设备日志编号为"' + deviceLogIds + '"的数据项？').then(function() {
        return delDevicelog(deviceLogIds);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('wx/devicelog/export', {
        ...this.queryParams
      }, `devicelog_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
